



<!doctype html>
<html lang="en" class="no-js">
  <head>

<style>
  h1, h2, h3 { color: #04A9F4; }
  pre { color: black !important; }
</style>


      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      <meta http-equiv="x-ua-compatible" content="ie=edge">

        <meta name="description" content="Open source package for Survival Analysis modeling">


        <link rel="canonical" href="https://www.pysurvival.io/models/semi_parametric.html">


        <meta name="author" content="The PySurvival Team">


        <meta name="lang:clipboard.copy" content="Copy to clipboard">

        <meta name="lang:clipboard.copied" content="Copied to clipboard">

        <meta name="lang:search.language" content="en">

        <meta name="lang:search.pipeline.stopwords" content="True">

        <meta name="lang:search.pipeline.trimmer" content="True">

        <meta name="lang:search.result.none" content="No matching documents">

        <meta name="lang:search.result.one" content="1 matching document">

        <meta name="lang:search.result.other" content="# matching documents">

        <meta name="lang:search.tokenizer" content="[\s\-]+">

      <link rel="shortcut icon" href="../images/favicon.ico">
      <meta name="generator" content="mkdocs-1.0.4, mkdocs-material-4.0.2">



        <title>Theory - PySurvival</title>



      <link rel="stylesheet" href="../assets/stylesheets/application.982221ab.css">

        <link rel="stylesheet" href="../assets/stylesheets/application-palette.224b79ff.css">




        <meta name="theme-color" content="#2196f3">



      <script src="../assets/javascripts/modernizr.1f0bcf2b.js"></script>



        <link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=:300,400,400i,700|">
        <style>body,input{font-family:"","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"","Courier New",Courier,monospace}</style>


    <link rel="stylesheet" href="../assets/fonts/material-icons.css">






  </head>



    <body dir="ltr" data-md-color-primary="blue" data-md-color-accent="purple">

    <svg class="md-svg">
      <defs>


          <svg xmlns="http://www.w3.org/2000/svg" width="416" height="448"
    viewBox="0 0 416 448" id="__github">
  <path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19-18.125
        8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19 18.125-8.5
        18.125 8.5 10.75 19 3.125 20.5zM320 304q0 10-3.125 20.5t-10.75
        19-18.125 8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19
        18.125-8.5 18.125 8.5 10.75 19 3.125 20.5zM360
        304q0-30-17.25-51t-46.75-21q-10.25 0-48.75 5.25-17.75 2.75-39.25
        2.75t-39.25-2.75q-38-5.25-48.75-5.25-29.5 0-46.75 21t-17.25 51q0 22 8
        38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0
        37.25-1.75t35-7.375 30.5-15 20.25-25.75 8-38.375zM416 260q0 51.75-15.25
        82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5-41.75
        1.125q-19.5 0-35.5-0.75t-36.875-3.125-38.125-7.5-34.25-12.875-30.25-20.25-21.5-28.75q-15.5-30.75-15.5-82.75
        0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25
        30.875q36.75-8.75 77.25-8.75 37 0 70 8 26.25-20.5
        46.75-30.25t47.25-9.75q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34
        99.5z" />
</svg>

      </defs>
    </svg>
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" data-md-component="overlay" for="__drawer"></label>

      <a href="#semi-parametriccox-proportional-hazard-models" tabindex="1" class="md-skip">
        Skip to content
      </a>


      <header class="md-header" data-md-component="header">
  <nav class="md-header-nav md-grid">
    <div class="md-flex">
      <div class="md-flex__cell md-flex__cell--shrink">
        <a href="https://www.pysurvival.io/" title="PySurvival" class="md-header-nav__button md-logo">

            <img src="../images/logo.ico" width="24" height="24">

        </a>
      </div>
      <div class="md-flex__cell md-flex__cell--shrink">
        <label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
      </div>
      <div class="md-flex__cell md-flex__cell--stretch">
        <div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">

            <span class="md-header-nav__topic">
              PySurvival
            </span>
            <span class="md-header-nav__topic">
              Theory
            </span>

        </div>
      </div>

              <!-- Global site tag (gtag.js) - Google Analytics -->
              <script async src="https://www.googletagmanager.com/gtag/js?id=UA-136790579-1"></script>
              <script>
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments);}
                gtag('js', new Date());

                gtag('config', 'UA-136790579-1');
              </script>

      <div class="md-flex__cell md-flex__cell--shrink">

          <label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>

<div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query" data-md-state="active">
      <label class="md-icon md-search__icon" for="__search"></label>
      <button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">
        &#xE5CD;
      </button>
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" data-md-scrollfix>
        <div class="md-search-result" data-md-component="result">
          <div class="md-search-result__meta">
            Type to start searching
          </div>
          <ol class="md-search-result__list"></ol>
        </div>
      </div>
    </div>
  </div>
</div>

      </div>

        <div class="md-flex__cell md-flex__cell--shrink">
          <div class="md-header-nav__source">





<a href="https://github.com/square/pysurvival/" title="Go to repository" class="md-source" >

    <div class="md-source__icon">
      <svg viewBox="0 0 24 24" width="24" height="24">
        <use xlink:href="#__github" width="24" height="24"></use>
      </svg>
    </div>

  <div class="md-source__repository">
    square/pysurvival
  </div>
</a>
          </div>
        </div>

    </div>
  </nav>
</header>

    <div class="md-container">




      <main class="md-main">
        <div class="md-main__inner md-grid" data-md-component="container">


              <div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    <nav class="md-nav md-nav--primary" data-md-level="0">
  <label class="md-nav__title md-nav__title--site" for="__drawer">
    <a href="https://www.pysurvival.io/" title="PySurvival" class="md-nav__button md-logo">

        <img src="../images/logo.ico" width="48" height="48">

    </a>
    PySurvival
  </label>

    <div class="md-nav__source">





<a href="https://github.com/square/pysurvival/" title="Go to repository" class="md-source" >

    <div class="md-source__icon">
      <svg viewBox="0 0 24 24" width="24" height="24">
        <use xlink:href="#__github" width="24" height="24"></use>
      </svg>
    </div>

  <div class="md-source__repository">
    square/pysurvival
  </div>
</a>
    </div>

  <ul class="md-nav__list" data-md-scrollfix>






  <li class="md-nav__item">
    <a href="../index.html" title="Home" class="md-nav__link">
      Home
    </a>
  </li>







  <li class="md-nav__item">
    <a href="../installation.html" title="Installation" class="md-nav__link">
      Installation
    </a>
  </li>







  <li class="md-nav__item">
    <a href="../intro.html" title="Introduction to Survival Analysis" class="md-nav__link">
      Introduction to Survival Analysis
    </a>
  </li>







  <li class="md-nav__item">
    <a href="../math.html" title="The math of Survival Analysis" class="md-nav__link">
      The math of Survival Analysis
    </a>
  </li>







  <li class="md-nav__item md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-5" type="checkbox" id="nav-5">

    <label class="md-nav__link" for="nav-5">
      Tutorials
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="1">
      <label class="md-nav__title" for="nav-5">
        Tutorials
      </label>
      <ul class="md-nav__list" data-md-scrollfix>







  <li class="md-nav__item">
    <a href="../tutorials/churn.html" title="Churn Prediction" class="md-nav__link">
      Churn Prediction
    </a>
  </li>







  <li class="md-nav__item">
    <a href="../tutorials/credit_risk.html" title="Credit Risk" class="md-nav__link">
      Credit Risk
    </a>
  </li>







  <li class="md-nav__item">
    <a href="../tutorials/employee_retention.html" title="Employee Retention" class="md-nav__link">
      Employee Retention
    </a>
  </li>







  <li class="md-nav__item">
    <a href="../tutorials/maintenance.html" title="Predictive Maintenance" class="md-nav__link">
      Predictive Maintenance
    </a>
  </li>


      </ul>
    </nav>
  </li>









  <li class="md-nav__item md-nav__item--active md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-6" type="checkbox" id="nav-6" checked>

    <label class="md-nav__link" for="nav-6">
      Models
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="1">
      <label class="md-nav__title" for="nav-6">
        Models
      </label>
      <ul class="md-nav__list" data-md-scrollfix>









  <li class="md-nav__item md-nav__item--active md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-6-1" type="checkbox" id="nav-6-1" checked>

    <label class="md-nav__link" for="nav-6-1">
      Cox Proportional Hazard
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="2">
      <label class="md-nav__title" for="nav-6-1">
        Cox Proportional Hazard
      </label>
      <ul class="md-nav__list" data-md-scrollfix>







  <li class="md-nav__item">
    <a href="coxph.html" title="Standard CoxPH  (API)" class="md-nav__link">
      Standard CoxPH  (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="nonlinear_coxph.html" title="DeepSurv/Nonlinear CoxPH (API)" class="md-nav__link">
      DeepSurv/Nonlinear CoxPH (API)
    </a>
  </li>









  <li class="md-nav__item md-nav__item--active">

    <input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="__toc">




      <label class="md-nav__link md-nav__link--active" for="__toc">
        Theory
      </label>

    <a href="semi_parametric.html" title="Theory" class="md-nav__link md-nav__link--active">
      Theory
    </a>


<nav class="md-nav md-nav--secondary">





    <label class="md-nav__title" for="__toc">Table of contents</label>
    <ul class="md-nav__list" data-md-scrollfix>

        <li class="md-nav__item">
  <a href="#cox-proportional-hazard-model" title="Cox Proportional Hazard model" class="md-nav__link">
    Cox Proportional Hazard model
  </a>

    <nav class="md-nav">
      <ul class="md-nav__list">

          <li class="md-nav__item">
  <a href="#hazard-functions-formula" title="Hazard function's formula" class="md-nav__link">
    Hazard function's formula
  </a>

</li>

          <li class="md-nav__item">
  <a href="#building-the-model" title="Building the model" class="md-nav__link">
    Building the model
  </a>

</li>

      </ul>
    </nav>

</li>

        <li class="md-nav__item">
  <a href="#deepsurvnonlinear-coxph-model" title="DeepSurv/NonLinear CoxPH model" class="md-nav__link">
    DeepSurv/NonLinear CoxPH model
  </a>

    <nav class="md-nav">
      <ul class="md-nav__list">

          <li class="md-nav__item">
  <a href="#hazard-functions-formula_1" title="Hazard function's formula" class="md-nav__link">
    Hazard function's formula
  </a>

</li>

          <li class="md-nav__item">
  <a href="#building-the-model_1" title="Building the model" class="md-nav__link">
    Building the model
  </a>

</li>

      </ul>
    </nav>

</li>

        <li class="md-nav__item">
  <a href="#references" title="References" class="md-nav__link">
    References
  </a>

</li>





    </ul>

</nav>

  </li>


      </ul>
    </nav>
  </li>







  <li class="md-nav__item md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-6-2" type="checkbox" id="nav-6-2">

    <label class="md-nav__link" for="nav-6-2">
      Multi-Task Logistic Regression (MTLR)
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="2">
      <label class="md-nav__title" for="nav-6-2">
        Multi-Task Logistic Regression (MTLR)
      </label>
      <ul class="md-nav__list" data-md-scrollfix>







  <li class="md-nav__item">
    <a href="linear_mtlr.html" title="Linear MTLR (API)" class="md-nav__link">
      Linear MTLR (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="neural_mtlr.html" title="Neural MTLR (API)" class="md-nav__link">
      Neural MTLR (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="mtlr_theory.html" title="Theory" class="md-nav__link">
      Theory
    </a>
  </li>


      </ul>
    </nav>
  </li>







  <li class="md-nav__item md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-6-3" type="checkbox" id="nav-6-3">

    <label class="md-nav__link" for="nav-6-3">
      Non-Parametric
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="2">
      <label class="md-nav__title" for="nav-6-3">
        Non-Parametric
      </label>
      <ul class="md-nav__list" data-md-scrollfix>







  <li class="md-nav__item">
    <a href="kaplan_meier.html" title="Kaplan Meier (API)" class="md-nav__link">
      Kaplan Meier (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="smooth_kaplan_meier.html" title="Smoothed Kaplan Meier (API)" class="md-nav__link">
      Smoothed Kaplan Meier (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="non_parametric.html" title="Theory" class="md-nav__link">
      Theory
    </a>
  </li>


      </ul>
    </nav>
  </li>







  <li class="md-nav__item md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-6-4" type="checkbox" id="nav-6-4">

    <label class="md-nav__link" for="nav-6-4">
      Parametric
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="2">
      <label class="md-nav__title" for="nav-6-4">
        Parametric
      </label>
      <ul class="md-nav__list" data-md-scrollfix>







  <li class="md-nav__item">
    <a href="parametric.html" title="Parametric models (API)" class="md-nav__link">
      Parametric models (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="parametric_theory.html" title="Theory" class="md-nav__link">
      Theory
    </a>
  </li>


      </ul>
    </nav>
  </li>







  <li class="md-nav__item md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-6-5" type="checkbox" id="nav-6-5">

    <label class="md-nav__link" for="nav-6-5">
      Simulation
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="2">
      <label class="md-nav__title" for="nav-6-5">
        Simulation
      </label>
      <ul class="md-nav__list" data-md-scrollfix>







  <li class="md-nav__item">
    <a href="simulations.html" title="Simulation models (API)" class="md-nav__link">
      Simulation models (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="simulations_theory.html" title="Theory" class="md-nav__link">
      Theory
    </a>
  </li>


      </ul>
    </nav>
  </li>







  <li class="md-nav__item md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-6-6" type="checkbox" id="nav-6-6">

    <label class="md-nav__link" for="nav-6-6">
      Survival Forest
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="2">
      <label class="md-nav__title" for="nav-6-6">
        Survival Forest
      </label>
      <ul class="md-nav__list" data-md-scrollfix>







  <li class="md-nav__item">
    <a href="conditional_survival_forest.html" title="Conditional Survival Forest (API)" class="md-nav__link">
      Conditional Survival Forest (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="extra_survival_trees.html" title="Extra Survival Trees (API)" class="md-nav__link">
      Extra Survival Trees (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="random_survival_forest.html" title="Random Survival Forest (API)" class="md-nav__link">
      Random Survival Forest (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="survival_forest.html" title="Theory" class="md-nav__link">
      Theory
    </a>
  </li>


      </ul>
    </nav>
  </li>







  <li class="md-nav__item md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-6-7" type="checkbox" id="nav-6-7">

    <label class="md-nav__link" for="nav-6-7">
      Survival SVM
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="2">
      <label class="md-nav__title" for="nav-6-7">
        Survival SVM
      </label>
      <ul class="md-nav__list" data-md-scrollfix>







  <li class="md-nav__item">
    <a href="linear_svm.html" title="Linear Survival SVM (API)" class="md-nav__link">
      Linear Survival SVM (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="kernel_svm.html" title="Kernel Survival SVM (API)" class="md-nav__link">
      Kernel Survival SVM (API)
    </a>
  </li>







  <li class="md-nav__item">
    <a href="survival_svm.html" title="Theory" class="md-nav__link">
      Theory
    </a>
  </li>


      </ul>
    </nav>
  </li>


      </ul>
    </nav>
  </li>







  <li class="md-nav__item md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-7" type="checkbox" id="nav-7">

    <label class="md-nav__link" for="nav-7">
      Performance metrics
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="1">
      <label class="md-nav__title" for="nav-7">
        Performance metrics
      </label>
      <ul class="md-nav__list" data-md-scrollfix>







  <li class="md-nav__item">
    <a href="../metrics/c_index.html" title="C-index" class="md-nav__link">
      C-index
    </a>
  </li>







  <li class="md-nav__item">
    <a href="../metrics/brier_score.html" title="Brier Score" class="md-nav__link">
      Brier Score
    </a>
  </li>


      </ul>
    </nav>
  </li>







  <li class="md-nav__item md-nav__item--nested">

      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-8" type="checkbox" id="nav-8">

    <label class="md-nav__link" for="nav-8">
      Miscellaneous
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="1">
      <label class="md-nav__title" for="nav-8">
        Miscellaneous
      </label>
      <ul class="md-nav__list" data-md-scrollfix>







  <li class="md-nav__item">
    <a href="../miscellaneous/activation_functions.html" title="Activation Functions" class="md-nav__link">
      Activation Functions
    </a>
  </li>







  <li class="md-nav__item">
    <a href="../miscellaneous/save_load.html" title="Saving/Loading models" class="md-nav__link">
      Saving/Loading models
    </a>
  </li>







  <li class="md-nav__item">
    <a href="../miscellaneous/tips.html" title="Tips for fitting models" class="md-nav__link">
      Tips for fitting models
    </a>
  </li>


      </ul>
    </nav>
  </li>


  </ul>
</nav>
                  </div>
                </div>
              </div>


              <div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">

<nav class="md-nav md-nav--secondary">





    <label class="md-nav__title" for="__toc">Table of contents</label>
    <ul class="md-nav__list" data-md-scrollfix>

        <li class="md-nav__item">
  <a href="#cox-proportional-hazard-model" title="Cox Proportional Hazard model" class="md-nav__link">
    Cox Proportional Hazard model
  </a>

    <nav class="md-nav">
      <ul class="md-nav__list">

          <li class="md-nav__item">
  <a href="#hazard-functions-formula" title="Hazard function's formula" class="md-nav__link">
    Hazard function's formula
  </a>

</li>

          <li class="md-nav__item">
  <a href="#building-the-model" title="Building the model" class="md-nav__link">
    Building the model
  </a>

</li>

      </ul>
    </nav>

</li>

        <li class="md-nav__item">
  <a href="#deepsurvnonlinear-coxph-model" title="DeepSurv/NonLinear CoxPH model" class="md-nav__link">
    DeepSurv/NonLinear CoxPH model
  </a>

    <nav class="md-nav">
      <ul class="md-nav__list">

          <li class="md-nav__item">
  <a href="#hazard-functions-formula_1" title="Hazard function's formula" class="md-nav__link">
    Hazard function's formula
  </a>

</li>

          <li class="md-nav__item">
  <a href="#building-the-model_1" title="Building the model" class="md-nav__link">
    Building the model
  </a>

</li>

      </ul>
    </nav>

</li>

        <li class="md-nav__item">
  <a href="#references" title="References" class="md-nav__link">
    References
  </a>

</li>





    </ul>

</nav>
                  </div>
                </div>
              </div>


          <div class="md-content">
            <article class="md-content__inner md-typeset">


                  <a href="https://github.com/square/pysurvival/edit/master/docs/models/semi_parametric.md" title="Edit this page" class="md-icon md-content__icon">&#xE3C9;</a>


                <!-- # Cox Proportional Hazard models-->

<style>
  h1, h2, h3 { color: #04A9F4; }
</style>

<h1 id="semi-parametriccox-proportional-hazard-models">Semi-Parametric/Cox Proportional Hazard models</h1>
<hr />
<h2 id="cox-proportional-hazard-model"><a href="coxph.html">Cox Proportional Hazard model</a></h2>
<h3 id="hazard-functions-formula">Hazard function's formula</h3>
<p>When it comes to predicting the survival function for a specific unit, the <a href="https://rss.onlinelibrary.wiley.com/doi/abs/10.1111/j.2517-6161.1972.tb00899.x">Cox Proportional Hazard Model (CoxPH)</a> is usually the go-to model.
The CoxPH model is a semi-parametric model that focuses on modeling the hazard function <script type="math/tex">h(t, x_i)</script>, by assuming that its time component <script type="math/tex">\lambda_0(t)</script> and feature component <script type="math/tex">\eta(\vec{x_i})</script> are proportional such that:
<script type="math/tex; mode=display">\begin{equation*}
h(t, \vec{x_i}) = \lambda_0(t)\eta(\vec{x_i})
\end{equation*}</script>
with:</p>
<ul>
<li>
<p>
<script type="math/tex">\lambda_0(t)</script>, is the baseline function, which is usually not specified.</p>
</li>
<li>
<p>
<script type="math/tex">\eta(\vec{x_i})</script>, is the risk function usually expressed via a linear representation such that <script type="math/tex">\eta(\vec{x_i}) = \exp \left( \sum_{j=1}^p x^i_j\omega_j \right)</script>. <script type="math/tex">\omega_j </script> are  the coefficients to determine</p>
</li>
</ul>
<h3 id="building-the-model">Building the model</h3>
<p>The model can be built by calculating the Efron's partial likelihood to take ties into account.
The partial likelihood <script type="math/tex">L(\omega)</script> can be written such that:
<script type="math/tex">\displaystyle L(\omega )=\prod _{j}{\frac {\prod _{i\in H_{j}}\theta _{i}}{\prod _{s =0}^{m_j-1}[\sum _{i:T_{i}\geq t_{j}}\theta _{i}-{\frac {s}{m_j}}\sum _{i\in H_{j}}\theta _{i}]}}.</script>
</p>
<ul>
<li>
<p>the log partial likelihood is <script type="math/tex">\displaystyle l (\omega )=\sum _{j}\left(\sum _{i\in H_{j}}X_{i}\cdot \omega -\sum _{s =0}^{m_j-1}\log(\phi _{j,s ,m_j})\right).</script>
</p>
</li>
<li>
<p>the gradient is <script type="math/tex">\displaystyle \vec{\nabla l(\omega )}=\sum _{j}\left(\sum _{i\in H_{j}}X_{i}-\sum _{s =0}^{m_j-1}{\frac {z_{j,s ,m_j}}{\phi _{j,s ,m_j}}}\right).</script>
</p>
</li>
<li>
<p>the Hessian matrix is <script type="math/tex">\displaystyle \nabla^2 l(\omega )=-\sum _{j}\sum _{s =0}^{m_j-1}\left({\frac {{Z}_{j,s ,m_j}}{\phi _{j,s ,m_j}}}-{\frac {z_{j,s ,m}z_{j,s ,m_j}^{T}}{\phi _{j,s ,m_j}^{2}}}\right).</script>
</p>
</li>
</ul>
<p>We can now use the <strong>Newton-Optimization schema</strong> to fit the model:
<script type="math/tex; mode=display">\begin{equation*}
\omega_{new} = \omega_{old} -  \nabla^2 l(\omega )^{-1} \cdot \vec{\nabla l(\omega )}
\end{equation*}</script>
</p>
<p>with:</p>
<ul>
<li>
<script type="math/tex">H_j = \left\{ i; T_i = t_j \text{ and } E_i = 1 \right \}</script>,  <script type="math/tex">{m_j} = \left|H_j \right|.</script>
</li>
<li>
<script type="math/tex">\theta _{i}= \exp\left(X_{i} \cdot \omega \right)</script>
</li>
<li>
<script type="math/tex">\phi _{j,s ,m_j}=\sum _{i:T_{i}\geq t_{j}}\theta _{i}-{\frac {s}{m_j}}\sum _{i\in H_{j}}\theta _{i}</script>
</li>
<li>
<script type="math/tex"> z_{j,s ,m_j}=\sum _{i:T_{i}\geq t_{j}}\theta _{i}X_{i}-{\frac {s }{m_j}}\sum _{i\in H_{j}}\theta _{i}X_{i}.</script>
</li>
<li>
<script type="math/tex"> {Z}_{j,s ,m_j}=\sum _{i:T_{i}\geq t_{j}}\theta _{i}X_{i}X_{i}^{T }-{\frac {s }{m_j}}\sum _{i\in H_{j}}\theta _{i}X_{i}X_{i}^{T}</script>
</li>
</ul>
<hr />
<h2 id="deepsurvnonlinear-coxph-model"><a href="nonlinear_coxph.html">DeepSurv/NonLinear CoxPH model</a></h2>
<h3 id="hazard-functions-formula_1">Hazard function's formula</h3>
<p>The NonLinear CoxPH model was popularized by Katzman et al. in <strong><a href="https://arxiv.org/pdf/1606.00931.pdf">DeepSurv: Personalized Treatment Recommender System Using A Cox Proportional Hazards Deep Neural Network</a></strong> by allowing the use of Neural Networks within the original design. Here the hazard function <script type="math/tex">h(t, x_i)</script> can be written as<br />
<script type="math/tex; mode=display">\begin{equation*}
h(t, \vec{x_i}) = \lambda_0(t)\Psi(\vec{x_i})
\end{equation*}</script>
</p>
<p>with:</p>
<ul>
<li>
<script type="math/tex">\Psi(\vec{x_i}) = \exp(\psi(\vec{x_i}))</script>, where <script type="math/tex">\psi</script> is a non-linear risk function.</li>
</ul>
<h3 id="building-the-model_1">Building the model</h3>
<p>We are still using the Efron's partial likelihood to take ties into account, but here the hazard function is <script type="math/tex">h(t, \vec{x_i}) = \lambda_0(t)\Psi(\vec{x_i})</script>. Thus, the log partial likelihood is
<script type="math/tex; mode=display">\begin{equation*}
l (\omega )=\sum _{j}\left(\sum _{i\in H_{j}}\log(\Psi(\vec{x_i})) -\sum _{s =0}^{m_j-1}\log \left(\sum _{i:T_{i}\geq t_{j}}\Psi(\vec{x_i})-{\frac {s }{m_j}}\sum _{i\in H_{j}}\Psi(\vec{x_i})\right)\right).
\end{equation*}</script>
</p>
<p>As the Hessian matrix will be too complicated to calculate, we will use <a href="https://pytorch.org/"><code>PyTorch</code></a> to compute the gradient and perform a First-Order optimization.</p>
<hr />
<h2 id="references">References</h2>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Proportional_hazards_model#Tied_times">Wikipedia - Proportional hazards model</a></li>
<li><a href="https://rss.onlinelibrary.wiley.com/doi/abs/10.1111/j.2517-6161.1972.tb00899.x">Cox, David R. "Regression models and life‐tables." Journal of the Royal Statistical Society: Series B (Methodological) 34.2 (1972): 187-202.</a></li>
<li><a href="https://arxiv.org/pdf/1606.00931.pdf">Katzman, Jared, et al. "DeepSurv: Personalized treatment recommender system using A Cox proportional hazards deep neural network." arXiv preprint arXiv:1606.00931 (2016).</a></li>
</ul>









            </article>
          </div>
        </div>
      </main>


<footer class="md-footer">

  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-footer-copyright">

          <div class="md-footer-copyright__highlight">
            Copyright &copy; 2019 Square Inc.
          </div>



        brought to you by
        <a href="https://squareup.com/us">
        <img src="images/Square_logo.png" alt="Square Logo" title="Square Logo" width=20%, height=20% align="center"  /></a>


      </div>

  <div class="md-footer-social">
    <link rel="stylesheet" href="../assets/fonts/font-awesome.css">

      <a href="https://pysurvival.io/" class="md-footer-social__link fa fa-home"></a>

      <a href="https://github.com/square/pysurvival" class="md-footer-social__link fa fa-github"></a>

  </div>

    </div>
  </div>
</footer>

    </div>

      <script src="../assets/javascripts/application.d9aa80ab.js"></script>

      <script>app.initialize({version:"1.0.4",url:{base:".."}})</script>

        <script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML"></script>

        <script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-annotation/0.5.7/chartjs-plugin-annotation.js"></script>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js"></script>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>


  </body>
</html>
